<html>
<head><meta charset="utf-8"><title>how much determinism · t-lang/wg-unsafe-code-guidelines · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/index.html">t-lang/wg-unsafe-code-guidelines</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html">how much determinism</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="136348375"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136348375" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136348375">(Oct 23 2018 at 16:28)</a>:</h4>
<p><span class="user-mention" data-user-id="124289">@rkruppe</span> I'm just getting to comments on <a href="https://github.com/rust-lang/rust/issues/31" target="_blank" title="https://github.com/rust-lang/rust/issues/31">#31</a>, and I'd like to know <a href="https://github.com/rust-rfcs/unsafe-code-guidelines/pull/31#discussion_r227469510" target="_blank" title="https://github.com/rust-rfcs/unsafe-code-guidelines/pull/31#discussion_r227469510">what you think of this</a>?</p>



<a name="136348987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136348987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136348987">(Oct 23 2018 at 16:38)</a>:</h4>
<p>My general position is that it's cool if it's some deterministic function, but if the inputs to that function are as expansive as they have to be to accommodate the current (lack of) consensus, that determinism isn't useful in practice. For example, Cargo passes very comprehensive hashes of the crate metadata and absolute paths, so it seems basically impossible to get the exact same command line twice unless you go to even more effort than typical reproducible build setups do</p>



<a name="136349198"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136349198" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136349198">(Oct 23 2018 at 16:42)</a>:</h4>
<p>OK. I don't disagree with that, I agree the set of inputs is pretty expansive. The phrasing I gave is basically "all compiler input"</p>



<a name="136349217"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136349217" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136349217">(Oct 23 2018 at 16:42)</a>:</h4>
<p>I suppose I said sort of two contradictory things</p>



<a name="136349237"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136349237" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136349237">(Oct 23 2018 at 16:43)</a>:</h4>
<p>maybe I'll just cut the opening paragraph more-or-less and run with this follow-on paragraph:</p>
<p>As of this writing, we have not reached a full consensus on what<br>
limitations should exist on possible field struct layouts. Therefore,<br>
the default layout of structs is considered undefined and subject to<br>
change between individual compilations. This implies that (among other<br>
things) two structs with the same field types may not be laid out in<br>
the same way (for example, the hypothetical struct representing tuples<br>
may be laid out differently from user-declared structs).</p>



<a name="136349238"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136349238" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136349238">(Oct 23 2018 at 16:43)</a>:</h4>
<p>which is basically what you were advocating <span class="user-mention" data-user-id="124289">@rkruppe</span></p>



<a name="136349309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136349309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136349309">(Oct 23 2018 at 16:44)</a>:</h4>
<p>I don't mind giving specific (non-exhaustive) examples of things that might influence layout</p>



<a name="136349362"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136349362" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136349362">(Oct 23 2018 at 16:45)</a>:</h4>
<p>But either way it should be clear that something like abomonation isn't covered by it</p>



<a name="136349565"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136349565" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136349565">(Oct 23 2018 at 16:49)</a>:</h4>
<p>what do you think of this:</p>
<p><strong>The default layout of structs is not specified.</strong> As of this<br>
writing, we have not reached a full consensus on what limitations<br>
should exist on possible field struct layouts, so effectively one must<br>
assume that the compiler can select any layout it likes on each<br>
compilation. This implies that (among other things) two structs with<br>
the same field types may not be laid out in the same way (for example,<br>
the hypothetical struct representing tuples may be laid out<br>
differently from user-declared structs).</p>
<p>Known things that can influence layout (non-exhaustive):</p>
<ul>
<li>the type of the struct fields and the layout of those types</li>
<li>compiler settings, including esoteric choices like optimization fuel</li>
<li>whether a given field was declared with a generic type or not<ul>
<li>this is necessary because the presence or absence of generics can<br>
  make a difference (e.g., <code>struct Foo { x: u16, y: u32 }</code> and<br>
<code>struct Foo&lt;T&gt; { x: u16, y: T }</code> where <code>T = u32</code> are not<br>
  guaranteed to be identical), owing to the possibility of unsizing<br>
  coercions</li>
</ul>
</li>
</ul>



<a name="136349773"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136349773" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136349773">(Oct 23 2018 at 16:52)</a>:</h4>
<p>One thing I'd call out in the first paragraph is choosing different layout for the <em>same</em> type across different compilations. It's heavily implied by everything else but I think it's worth calling out in those words because it's just as subtle and important as the case of two distinct but structually-identical types in one compilation.</p>



<a name="136349991"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136349991" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136349991">(Oct 23 2018 at 16:56)</a>:</h4>
<blockquote>
<ul>
<li>whether a given field was declared with a generic type or not<ul>
<li>this is necessary because the presence or absence of generics can<br>
  make a difference (e.g., <code>struct Foo { x: u16, y: u32 }</code> and<br>
<code>struct Foo&lt;T&gt; { x: u16, y: T }</code> where <code>T = u32</code> are not<br>
  guaranteed to be identical), owing to the possibility of unsizing<br>
  coercions</li>
</ul>
</li>
</ul>
</blockquote>
<p>Come to think of it, this seems a bit out of place now. It's an important observation as soon as we try to guarantee that two structs with (in some precise sense) equivalent fields are laid out the same, but since the current text doesn't do anything like that...</p>



<a name="136350001"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136350001" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136350001">(Oct 23 2018 at 16:56)</a>:</h4>
<p>yes, but</p>



<a name="136350003"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136350003" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136350003">(Oct 23 2018 at 16:57)</a>:</h4>
<p>I opted to include it because</p>



<a name="136350011"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136350011" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136350011">(Oct 23 2018 at 16:57)</a>:</h4>
<p>it just seemed like something worth knowing</p>



<a name="136350017"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136350017" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136350017">(Oct 23 2018 at 16:57)</a>:</h4>
<p>I guess because <em>in practice</em> if you are trying to understand what the compiler <em>really does</em></p>



<a name="136350018"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136350018" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136350018">(Oct 23 2018 at 16:57)</a>:</h4>
<p>you would like to know it</p>



<a name="136350019"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136350019" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136350019">(Oct 23 2018 at 16:57)</a>:</h4>
<p>perhaps I'll move it down to the "Compiler's current behavior" section</p>



<a name="136350023"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136350023" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136350023">(Oct 23 2018 at 16:57)</a>:</h4>
<p>yes that seems better</p>



<a name="136350076"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136350076" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136350076">(Oct 23 2018 at 16:58)</a>:</h4>
<p>understanding the current behavior tends to be an obstacle to knowing what one can rely on :)</p>



<a name="136350228"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136350228" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136350228">(Oct 23 2018 at 17:00)</a>:</h4>
<p>I also added</p>
<p><strong>A note on determinism.</strong> The definition above does not guarantee<br>
determinism between executions of the compiler -- two executions may<br>
select different layouts. Naturally, in practice, the compiler aims to<br>
produce deterministic output. However, it is difficult to produce a<br>
comprehensive summary of the various factors that may affect the<br>
layout of structs, and so for the time being we have opted for a<br>
conservative definition.</p>



<a name="136350308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136350308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136350308">(Oct 23 2018 at 17:02)</a>:</h4>
<p>did you see <a href="https://github.com/rust-rfcs/unsafe-code-guidelines/pull/31#discussion_r227478178" target="_blank" title="https://github.com/rust-rfcs/unsafe-code-guidelines/pull/31#discussion_r227478178">this</a>? I wasn't aware that <code>#[repr(C)] struct Foo { }</code> had zero-size...</p>



<a name="136350310"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136350310" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136350310">(Oct 23 2018 at 17:02)</a>:</h4>
<p>tbh I hadn't really thought about it :P</p>



<a name="136350438"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136350438" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136350438">(Oct 23 2018 at 17:04)</a>:</h4>
<p>yeah, it's annoying for hand-written bindings but otherwise probably not an issue. tbh even if one messes that up it seems hard to write a program that will actually go wrong because of that difference (I expect that accesses to struct Foo {} are nops in C too)</p>



<a name="136350707"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136350707" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136350707">(Oct 23 2018 at 17:08)</a>:</h4>
<p>yeah by-value passing and load/stores of empty structs are nops in C <a href="https://godbolt.org/z/Y02oVi" target="_blank" title="https://godbolt.org/z/Y02oVi">https://godbolt.org/z/Y02oVi</a></p>



<a name="136351558"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136351558" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136351558">(Oct 23 2018 at 17:20)</a>:</h4>
<p>in the x86 and x86_64 SysV ABIs, I should say</p>



<a name="136351837"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136351837" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136351837">(Oct 23 2018 at 17:24)</a>:</h4>
<p>I'd be more concerned about the layout of things that embed empty structs being different in subtle ways</p>



<a name="136353178"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136353178" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136353178">(Oct 23 2018 at 17:41)</a>:</h4>
<p>oh good point</p>



<a name="136370028"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136370028" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136370028">(Oct 23 2018 at 21:54)</a>:</h4>
<blockquote>
<p>But either way it should be clear that something like abomonation isn't covered by it</p>
</blockquote>
<p>What is abomonation doing that you are referring to here?</p>



<a name="136370256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136370256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136370256">(Oct 23 2018 at 21:59)</a>:</h4>
<p>I am referring to assuming the same program compiled twice by the same rustc version will have the same layout for everything. That isn't inherent in abomonation itself but <em>using it</em> generally requires that because e.g. you're communicating between a cdylib and a binary that include the same source files</p>



<a name="136370364"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136370364" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136370364">(Oct 23 2018 at 22:00)</a>:</h4>
<p>ah you mean essentially dumping the raw memory representation into a file, and reading it back later with just some fixes for ptrs?</p>



<a name="136370404"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136370404" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136370404">(Oct 23 2018 at 22:01)</a>:</h4>
<p>that's basically what abomonation does, yes</p>



<a name="136370872"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136370872" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136370872">(Oct 23 2018 at 22:11)</a>:</h4>
<p>well, for me the core thing was always that it also plays crazy tricks with lifetimes and references, that's why I was confused at first^^</p>



<a name="136370954"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136370954" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136370954">(Oct 23 2018 at 22:13)</a>:</h4>
<p>oh right, there's plenty there to be proven sound there, I was only thinking about layout stuff</p>



<a name="136440985"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136440985" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136440985">(Oct 24 2018 at 22:35)</a>:</h4>
<p><span class="user-mention" data-user-id="124289">@rkruppe</span> to be clear, that is C++</p>



<a name="136440989"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136440989" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136440989">(Oct 24 2018 at 22:35)</a>:</h4>
<p>C does not have empty structs</p>



<a name="136441088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136441088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136441088">(Oct 24 2018 at 22:38)</a>:</h4>
<p>My godbolt link was running clang in c++ mode, yes. clang's and gcc's c mode also accept empty structs though, so we'll want interop with that no matter what the c standard says</p>



<a name="136441135"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136441135" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136441135">(Oct 24 2018 at 22:38)</a>:</h4>
<p>clang and gcc's C mode have empty structs with size 0.</p>



<a name="136441162"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136441162" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136441162">(Oct 24 2018 at 22:39)</a>:</h4>
<p>huh, indeed</p>



<a name="136441180"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136441180" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136441180">(Oct 24 2018 at 22:39)</a>:</h4>
<p>thanks for pointing that out</p>



<a name="136441269"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136441269" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136441269">(Oct 24 2018 at 22:40)</a>:</h4>
<p><a href="https://godbolt.org/z/AS2gdC" target="_blank" title="https://godbolt.org/z/AS2gdC">https://godbolt.org/z/AS2gdC</a></p>



<a name="136441477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136441477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136441477">(Oct 24 2018 at 22:44)</a>:</h4>
<p>no worries, it's a common bit of confusion :)</p>



<a name="136441495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how%20much%20determinism/near/136441495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/how.20much.20determinism.html#136441495">(Oct 24 2018 at 22:44)</a>:</h4>
<p>especially among C++ programmers who think it's shitty that <code>Bar</code> takes up more than four bytes of space, cough cough :&lt;</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>